package restful;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.sun.grizzly.http.SelectorThread;
import com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory;

public class RestEndpoint {
	public static void main(String[] args) throws IOException {
	
		String baseUri = "http://localhost:9998/";
		if(System.getenv().containsKey("BaseUri")){
			baseUri = System.getenv("BaseUri");
		}
		Map<String, String> initParams = new HashMap<String, String>();

		initParams.put("com.sun.jersey.config.property.packages",
				"restful.service");

		System.out.println("Starting grizzly...");
		System.out.println("Service available at: " + baseUri + "meterreadings/meter/{meterID}/{tStart}/{tEnd}/{interval}");
		SelectorThread threadSelector = GrizzlyWebContainerFactory.create(
				baseUri, initParams);		
		System.out.println("REST Endpoint started.");
		System.in.read();
		threadSelector.stopEndpoint();
		System.exit(0);
	}
}
